package com.zlc.workflow.core.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zlc.common.common.entity.PageVo;
import com.zlc.common.core.process.model.entity.StoneNodeApproveUserConfig;
import com.zlc.common.core.process.model.vo.StoneNodeApproveUserConfigVo;
import com.zlc.common.core.process.model.vo.StoneSystemVo;
import com.zlc.common.core.process.service.StoneNodeApproveUserConfigService;
import com.zlc.common.model.process.system.SystemRequestParam;
import com.zlc.common.model.user.LoginParam;
import com.zlc.common.util.BeanCopyUtils;
import com.zlc.workflow.core.system.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "流程系统配置")
@RestController
@Slf4j
@RequestMapping("/api/system")
public class StoneSysController {

    @Autowired
    private SystemService systemService;

    /**
     * 查询系统
     */
    @ApiOperation(value = "查询系统")
    @GetMapping(value = "/queryList")
    public PageVo<StoneSystemVo> queryList(SystemRequestParam requestParam){
        return systemService.queryList(requestParam);
    }

    /**
     * 添加系统
     */
    @ApiOperation(value = "添加系统")
    @PostMapping(value = "/add")
    public void add(@RequestBody StoneSystemVo systemVo){
        systemService.add(systemVo);
    }

    /**
     * 保存系统
     */
    @ApiOperation(value = "保存系统")
    @PostMapping(value = "/save")
    public void save(@RequestBody StoneSystemVo systemVo){
        systemService.save(systemVo);
    }

    /**
     * 删除系统
     */
    @ApiOperation(value = "保存系统")
    @GetMapping(value = "/remove")
    public void remove(@RequestParam String id){
        systemService.remove(id);
    }

    @Autowired
    private StoneNodeApproveUserConfigService stoneNodeApproveUserConfigService;
    /**
     * 测试
     */
    @ApiOperation(value = "测试")
    @GetMapping(value = "/test")
    public void test(){
        StoneNodeApproveUserConfigVo vo = stoneNodeApproveUserConfigService.queryVoList(new LambdaQueryWrapper<>()).get(0);
        StoneNodeApproveUserConfig config = BeanCopyUtils.copyObj(vo,StoneNodeApproveUserConfig.class);
        stoneNodeApproveUserConfigService.updateById(config);
    }
}
